package codetop;

public class lc11_max_water {
    public static void main(String[] args) {
        System.out.println(maxArea(new int[]{1,8,6,2,5,4,8,3,7}));
    }
    public static int maxArea(int[] height) {
        /**
         * 双指针
         */
        int start = 0, end = height.length - 1;
        int re = 0;
        while(start < end){
            int water = (end - start) * Math.min(height[end], height[start]);
            re = Math.max(water, re);
            if(height[start] < height[end])
                start++;
            else
                end--;
        }
        return re;
    }
}
